package org.cfg;

import com.sojoys.artifact.build.data.base.BaseCfg;
import com.sojoys.artifact.tools.ToolMap;
import com.sojoys.artifact.tools.ToolCopy;
import com.sojoys.artifact.factory.bytebuff.IByteBuff;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import com.sojoys.artifact.constant.DataModelKeyEnum;
/**
 * 召唤合成
 */
public class SummonComposeCfg extends BaseCfg<SummonComposeCfg> {

	/**
	 * 数据库表名称
	 */
	public static final String TABLE_NAME = "summon_compose";
	/**
	 * 完整类名称
	 */
	public static final String CLASS_NAME = "org.cfg.SummonComposeCfg"; 
	/**
	 * 字段个数
	 */
	public static final int COLUMN_COUNT= 6;
	/**
	 * 数据库源字段注释
	 */
	public static final String[] SOURCE_COLUMN_REMARKS = new String[]{"","池类型","质点类型","配方等级","消耗","合成时间",};
	/**
	 * 数据库源字段名字
	 */
	public static final String[] SOURCE_COLUMN_NAMES = new String[]{"id","poolType","zPointType","level","cost","time",};
	/**
	 * 拼音字段名字
	 */
	public static final String[] PINGYING_COLUMN_NAMES = new String[]{"id","poolType","zPointType","level","cost","time",};
	/**
	 * HashCode字段名字
	 */
	public static final Integer[] HASHCODE_COLUMN_NAMES = new Integer[]{3355,635121014,1068702096,102865796,3059661,3560141,};
	/**
	 * 字段基本类型
	 */
	public static final String[] COLUMN_BASICTYPES = new String[]{"int","int","int","int","Map","int",};
	/**
	 * 字段引用类型
	 */
	public static final Class[] COLUMN_CLASSTYPES = new Class[]{Integer.class,Integer.class,Integer.class,Integer.class,Map.class,Integer.class,};
	
	/**
	 * id
	 */
	private int id;
	
	/**
	 * 池类型
	 */
	private int poolType;
	
	/**
	 * 质点类型
	 */
	private int zPointType;
	
	/**
	 * 配方等级
	 */
	private int level;
	
	/**
	 * 消耗
	 */
	private Map cost;
	
	/**
	 * 合成时间
	 */
	private int time;
	
	
	
	public static SummonComposeCfg builder() {
		SummonComposeCfg summonComposeCfg = new SummonComposeCfg();
		return summonComposeCfg;
	}
	
	/**
	 * id
	 */
	public int getId() {
		return id;
	}
	
	/**
	 * 池类型
	 */
	public int getPoolType() {
		return poolType;
	}
	
	/**
	 * 质点类型
	 */
	public int getZPointType() {
		return zPointType;
	}
	
	/**
	 * 配方等级
	 */
	public int getLevel() {
		return level;
	}
	
	/**
	 * 消耗
	 */
	public Map getCost() {
		return cost;
	}
	
	/**
	 * 合成时间
	 */
	public int getTime() {
		return time;
	}
	
	
	protected Object[] getColumnNames(DataModelKeyEnum e){
		switch (e) {
		case SOURCE:
			return SOURCE_COLUMN_NAMES;
		case PINGYING:
			return PINGYING_COLUMN_NAMES;
		case HASHCODE:
			return HASHCODE_COLUMN_NAMES;
		case REMARKS:
			return SOURCE_COLUMN_REMARKS;
		default:
			return PINGYING_COLUMN_NAMES;
		}
	}
	
	protected String[] getBasicTypes(){
		return COLUMN_BASICTYPES;
	}
	
	protected Class[] getClassTypes(){
		return COLUMN_CLASSTYPES;
	}
	
	protected Object[] getColumeValues(){
		Object[] values = new Object[COLUMN_COUNT];
        values[0] = this.id;
        values[1] = this.poolType;
        values[2] = this.zPointType;
        values[3] = this.level;
        values[4] = this.cost;
        values[5] = this.time;
        return values;
	}
	
	protected SummonComposeCfg createColumeValues(Object[] vals) {
		this.id = (int)vals[0];
		this.poolType = (int)vals[1];
		this.zPointType = (int)vals[2];
		this.level = (int)vals[3];
		this.cost = (Map)vals[4];
		this.time = (int)vals[5];
		return this;
	}
	
	protected Map<Object, Object> toMap(Object[] keys,Map<Object, Object> map){
        map.put(keys[0], this.id);
        map.put(keys[1], this.poolType);
        map.put(keys[2], this.zPointType);
        map.put(keys[3], this.level);
        map.put(keys[4], this.cost);
        map.put(keys[5], this.time);
        return map;
    }
    
    protected SummonComposeCfg createForMap(Object[] keys,Map map){
   		this.id = (int)map.get(keys[0]);
   		this.poolType = (int)map.get(keys[1]);
   		this.zPointType = (int)map.get(keys[2]);
   		this.level = (int)map.get(keys[3]);
   		this.cost = (Map)map.get(keys[4]);
   		this.time = (int)map.get(keys[5]);
        return this;
    }
	
	
	protected JSONObject toJSONObject(Object[] keys,JSONObject obj){
        obj.put(keys[0], this.id);
        obj.put(keys[1], this.poolType);
        obj.put(keys[2], this.zPointType);
        obj.put(keys[3], this.level);
        obj.put(keys[4], this.cost);
        obj.put(keys[5], this.time);
        return obj;
    }
    
    protected SummonComposeCfg createForJSONObject(Object[] keys,JSONObject obj){
	    this.id = obj.getIntValue(keys[0]);
	    this.poolType = obj.getIntValue(keys[1]);
	    this.zPointType = obj.getIntValue(keys[2]);
	    this.level = obj.getIntValue(keys[3]);
		this.cost = obj.getObject(keys[4],Map.class);
	    this.time = obj.getIntValue(keys[5]);
        return this;
    }
    
    protected void writeBytes(IByteBuff byteBuf){
	    byteBuf.writeInt(this.id);
	    byteBuf.writeInt(this.poolType);
	    byteBuf.writeInt(this.zPointType);
	    byteBuf.writeInt(this.level);
	    byteBuf.writeObject(this.cost);
	    byteBuf.writeInt(this.time);
    }
	
	protected SummonComposeCfg readBytes(IByteBuff byteBuf){
	    this.id = byteBuf.readInt(null);
	    this.poolType = byteBuf.readInt(null);
	    this.zPointType = byteBuf.readInt(null);
	    this.level = byteBuf.readInt(null);
	    this.cost = (Map)byteBuf.readObject();
	    this.time = byteBuf.readInt(null);
	    return this;
	}
	
	public SummonComposeCfg deepCopy(){
		SummonComposeCfg summonComposeCfg = null;
		try {
			summonComposeCfg = (SummonComposeCfg) super.clone();
		    summonComposeCfg.cost = ToolCopy.copyObject(this.cost);
			return summonComposeCfg;
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return summonComposeCfg;
	}
//自定义内容起始位置
//自定义内容结束位置
}
